package com.fbinggun.dt.task.conditions;

import com.fbinggun.dt.task.Task;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityDeathEvent;

import java.sql.SQLException;

public class KillPlayer extends Conditions{
    public KillPlayer(String id, ConfigurationSection config, Task task) {
        super(id, config, task);
    }

    @EventHandler
    public void on(EntityDeathEvent event) throws SQLException, ClassNotFoundException {
        if(event.getEntity() instanceof Player) {
            if (event.getEntity().getKiller() != null) {
                Player player = event.getEntity().getKiller();
                if (isRun(player)) {
                        addCount(player, 1);
                }
            }
        }

    }
}
